/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.asportoonline.business.beans;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.asportoonline.entities.Cliente;
import org.asportoonline.entities.Locale;
import org.asportoonline.integration.LocaleFacade;

/**
 *
 * @author fe
 */
@Stateless
public class LocaleManagerImplementation implements LocaleManager {
    @EJB
    private LocaleFacade localeFacade;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public List<Locale> elencoLocali() {
        return localeFacade.findAll();
    }

    @Override
    public void inserisciLocale(Locale locale) {
        localeFacade.create(locale);
    }

    @Override
    public Locale cercaLocale(long id) {
        return localeFacade.find(id);
    }
    
    public Locale cercaLocale(String nome) {
        return localeFacade.find(nome);
    }
    
    public List<Locale> recuperaLocaliVenditore(Cliente c) {
        return localeFacade.fetch_vendor_locals(c);
    }

    public void aggiornaLocale(Locale locale) {
        localeFacade.edit(locale);
    }

    public List<String> recuperaTutteLeLocalita() {
        return localeFacade.fetch_all_locality();
    }

    public List<Locale> cercaPerLocalita(String localita) {
        return localeFacade.find_for_locality(localita);
    }
    
    
}
